ARG UBUNTU_VERSION=22.04
ARG ARCH=x86_64
ARG PYTHON_VERSION=3.10

FROM ubuntu:$UBUNTU_VERSION
SHELL ["bash", "-c"]

ENV DEBIAN_FRONTEND=noninteractive

# docker build -t ubuntu:22.04-py3.10 . --no-cache
RUN apt-get update && apt-get install -y \
    build-essential \
    ca-certificates \
    pkg-config \
    curl \
    zlib1g-dev \
    libssl-dev \
    libffi-dev \
    libhdf5-dev \
    libopenmpi-dev \
    libbz2-dev \
    liblzma-dev \
    libomp-dev \
    libgl1-mesa-dev \
    libncurses5-dev \
    libncursesw5-dev \
    libre2-dev \
    libb64-dev \
    numactl \
    libgl1-mesa-glx \
    libarchive13 \
    wget && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# 更新包列表并安装必要的依赖
RUN apt-get update && \
    apt-get install -y software-properties-common && \
    add-apt-repository ppa:deadsnakes/ppa && \
    apt-get update && \
    apt-get install -y python3.10 && \
    apt-get clean && \
    apt-get install -y python3.10  && \
    apt-get install -y python3-pip && \
    apt-get install -y git         && \
    rm -rf /var/lib/apt/lists/*


# 设置 Python 3.10 为默认的 Python 解释器
RUN ln -s /usr/bin/python3.10 /usr/bin/python

## 安装 python pypi
# RUN pip install distutils -U -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
RUN python -m pip install --upgrade pip -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
RUN pip3 config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
RUN pip3 install --upgrade cython --no-cache-dir


# 更换阿里源: https://www.cnblogs.com/liujiaxin2018/p/16373668.html
RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak
RUN echo    "deb http://mirrors.aliyun.com/ubuntu/    jammy main restricted universe multiverse             \
            deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse             \
            deb http://mirrors.aliyun.com/ubuntu/     jammy-security main restricted universe multiverse    \
            deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse    \
            deb http://mirrors.aliyun.com/ubuntu/     jammy-updates main restricted universe multiverse     \
            deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse     \
            deb http://mirrors.aliyun.com/ubuntu/     jammy-proposed main restricted universe multiverse    \
            deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse    \
            deb http://mirrors.aliyun.com/ubuntu/     jammy-backports main restricted universe multiverse   \
            deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse"  \
        > /etc/apt/sources.list
RUN apt-get update
RUN pip cache purge


CMD ["/bin/bash"]